﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Linq;
using Tong;

public partial class aspnet_testPargrameDir_site_Member_Login : System.Web.UI.Page
{
    /// <summary>
    /// 用於顯示資料
    /// </summary>
    public Tong.TongUse TextData = new Tong.TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();

    public string ho = "";

    /// <summary>
    /// 站点通用方法类
    /// </summary>
    public Tong.ThisSiteUse.SiteTong TextThisSite = new Tong.ThisSiteUse.SiteTong();


    //得到传入的栏目ID
    public String CloumnID = "1";

    /// <summary>
    /// 顯示當前欄目的簡介
    /// </summary>
    public string str1 = "";
    /// <summary>
    /// 資料表
    /// </summary>
    DataTable NewDt = new DataTable();
    /// <summary>
    /// 用于分頁的對像
    /// </summary>
    Tong.Fy.FenYe FY = new Tong.Fy.FenYe();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] != null)
        {
            Response.Redirect("Me.aspx");
        }
    }
    /// <summary>
    /// 登录系统
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(stuid.Text))
        {
            TextData.ResonseAlert("请输入会员号");
            return;
        }

        string studid = stuid.Text;
        decimal stid = 0;
        decimal.TryParse(studid, out stid);
        JModel.DBEntities db = new JModel.DBEntities();
        var query = db.CX_Student.Where(p => p.学号 == stid);
        if (query.Count() == 0)
        {
            TextData.ResonseAlert("您输入的会员号不存在,请联系学样获取正确的学号");
            return;
        }

        var queryst = db.RegUser.Where(p => p.RegUser_LX == stid && p.RegUser_CreatefileName== pwd.Value);
        if (queryst.Count() == 0)
        {
            TextData.ResonseAlert("您输入的会员号,或者密码不正确");
            return;
        }
        else
        {

        }
        Session["user"] = query.FirstOrDefault();
        Response.Cookies["admin"].Value = query.FirstOrDefault().姓名;//便用cookie写入

        db.Connection.Close();
        db.Dispose();

        Response.Redirect("Me.aspx");

    }
}